﻿using System;
using System.Collections.Generic;
using System.Web;

/// <summary>
/// Summary description for ClassName
/// </summary>
public class CashCardApp
{
    public CashCardApp()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    
    public static int NewCashCardApp(CustomerCashCard c){
        
        string sql = @"INSERT INTO CustomerCashCard(
            CashCardAppNo,
            CustomerId,
            ApplicationDate,
            CashCardStatus,
            CashCardStatusDate,
            DocumentStatus,
            CashCardNo,
            CashCardType,
            PartnerBank,
            StatusDate,
            NameOnCard,
            CardExpDate,
            CardDelStatus,
            DelStatusDate,
            CardDelCourier,
            DelDate,
            Remarks,
            DateCreated,
            DateUpdated
            )
            VALUES(@0,@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14,@15,@16,@17,@18)";
         List<object> param = new List<object>();
           
            param.Add(c.CashCardAppNo);
            param.Add(c.CustomerID);
            param.Add(c.ApplicationDate);
            param.Add(c.CashCardStatus);
            param.Add(c.CashCardStatusDate);
            param.Add(c.DocumentStatus);
            param.Add(c.CashCardNo);
            param.Add(c.CashCardType);
            param.Add(c.PartnerBank);
            param.Add(c.StatusDate);
            param.Add(c.NameOnCard);
            param.Add(c.CardExpDate);
            param.Add(c.CardDelStatus);
            param.Add(c.DelStatusDate);
            param.Add(c.CardDelCourier);
            param.Add(c.DelDate);
            param.Add(c.Remarks);
            param.Add(c.DateCreated);
            param.Add(c.DateUpdated);
        
          var result = DBManager.Execute(sql,param.ToArray());
          return result;
          
    }
    
    public static int UpdateCustomer(CustomerCashCard c){
       string sql=@"UPDATE Customer SET
                    CustomerClassification=@0,
                    CustomerStatus=@1,
                    Country=@2,
                    Gender=@3,
                    Nationality=@4,
                    Bdate=@5,
                    PlaceOfBirth=@6,
                    IDNumber=@7,
                    IDType=@8,
                    SrcOfFunds=@9,
                    Employment=@10,
                    Employer=@11,
                    NatureOfWork=@12,
                    DateUpdated=@13
                    WHERE CustomerID=@14";
        
         List<object> param = new List<object>();
            param.Add(c.CustomerClassification);
            param.Add(c.CustomerStatus);
            param.Add(c.Country);
            param.Add(c.Gender);
            param.Add(c.Nationality);
            param.Add(c.Bdate);
            param.Add(c.PlaceOfBirth);
            param.Add(c.IDNumber);
            param.Add(c.IDType);
            param.Add(c.SrcOfFunds);
            param.Add(c.Employment);
            param.Add(c.Employer);
            param.Add(c.NatureOfWork);
            param.Add(c.DateUpdated);
            param.Add(c.CustomerID);
       return DBManager.Execute(sql,param.ToArray());  
    }
    
    public static IEnumerable<dynamic> ExtractDataOfCustomer(string c){
       string sql=@"SELECT CustomerID,
                        CustomerClassification,
                        CustomerStatus,
                        Country,
                        Gender,
                        Nationality,
                        Bdate,
                        PlaceOfBirth,
                        IDNumber,
                        IDType,
                        SrcOfFunds,
                        Employment,
                        Employer,
                        NatureOfWork
                    FROM Customer
                    WHERE CustomerID=@0";
        
        var query = DBManager.Query(sql,new object[]{c});
        return query;
    }
    
    
    
}
